#pragma once

//#include <srs_app_encoder.hpp>
#include <srs_core.hpp>

#ifdef SRS_AUTO_TRANSCODE

#include <string>
#include <vector>

#include <srs_app_thread.hpp>

class SrsConfDirective;
class SrsRequest;
class SrsPithyPrint;
class SrsFFMPEG;

/**
* the encoder for a stream,
* may use multiple ffmpegs to transcode the specified stream.
*/
class SrsEncoder : public ISrsReusableThreadHandler {
private:
    std::string input_stream_name;
    std::vector<SrsFFMPEG*> ffmpegs;
private:
    SrsReusableThread* pthread;
    SrsPithyPrint* pprint;
public:
    SrsEncoder();
    virtual ~SrsEncoder();
public:
    virtual int on_publish(SrsRequest* req);
    virtual void on_unpublish();
    // interface ISrsReusableThreadHandler.
public:
    virtual int cycle();
    virtual void on_thread_stop();
private:
    virtual void clear_engines();
    virtual SrsFFMPEG* at(int index);
    virtual int parse_scope_engines(SrsRequest* req);
    virtual int parse_ffmpeg(SrsRequest* req, SrsConfDirective* conf);
    virtual int initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsRequest* req, SrsConfDirective* engine);
    virtual void show_encode_log_message();
};

#endif
